#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int main()
{
    char path[128] = "./";

    DIR *pd = opendir(path);
    if (pd == NULL)
    {
        perror("opendir");
        return -1;
    }

    struct dirent* p;
    struct stat buf;
    int ret;
    while (p = readdir(pd))
    {
        char file_name[1024] = {0};
        sprintf(file_name, "%s%s%s", path, "/", p->d_name);

        ret = stat(file_name, &buf);

        printf("%6ld %s\n", buf.st_size, p->d_name);
    }
    closedir(pd);
    return 0;
}